//
//  CoreDataManager.h
//  CoreDataDemo
//
//  Created by liuxiang on 2018/1/5.
//  Copyright © 2018年 liuxiang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

#define IsiOS10 [[[UIDevice currentDevice] systemVersion] floatValue] > 12.0

static NSString *MCDeleteResultBoolKey = @"deleteResult";
static NSString *MCDeleteManagerObjectsKey = @"deleteManagerObjects";

@interface CoreDataManager : NSObject

+ (instancetype) sharedCoreDataManager;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;

- (BOOL) excuteInsertWithObjects:(NSArray<NSManagedObject *> *)mbs;

/**
 coreData 查询
 @param entityName 查询表（实体）
 @param predicateString 查询条件
 @param limitCount 查询个数
 @param sortKey 排序字段
 @param ascending 升序/降序
 @return 查询结果
 */
- (nullable NSArray<NSManagedObject *> *) excuteQueryWithEntityName:(NSString *)entityName condition:(NSString *)predicateString limitCount:(NSUInteger) limitCount sortKeys:(NSArray *)sortKeys ascending:(BOOL)ascending;


/**
 coreData 删除
 @param entityName 查询表（实体）
 @param predicateString 删除条件
 @return 删除结果  MCDeleteResultBoolKey:BOOL,MCDeleteManagerObjectsKey:<NSManagedObject *>
 */
- (nullable NSDictionary<NSString *, id> *) excuteDeleteWithEntityName:(NSString *_Nonnull)entityName Condition:(NSString *_Nullable)predicat_NullableeString;

- (BOOL) excuteDeleteWithObjects:(NSArray<NSManagedObject *> *_Nonnull)objs;

- (BOOL) excuteUpdateWithObjects;


- (BOOL)saveContext;

- (BOOL) insertDataFromSql;


@end
